<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>我发布的微博</h1>
<div>
  <div v-for="weibo in arr">
    <h3>{{weibo.title}} <a href="javascript:void (0)" @click="del(weibo.id)">删除</a></h3>
    <p>{{weibo.content}}</p>
    <img :src="weibo.url" style="width: 200px" alt="">
  </div>
</div>
<!--引入axios和vue-->
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script>
  let v = new Vue({
    el:"body>div",
    data:{
      arr:[]
    },
    created:function () {
        //请求当前登录用户发布的所有微博
      axios.get("/weibo/select/my").then(function (response) {
          //判断出未登录的状态
          if(response.data.status==2){
              alert("请先登录!")
              location.href = "/login.html";
              return;
          }
        v.arr = response.data.content;
      })
    },
      methods:{
        del:function (id) {
            if(confirm("您确认删除此微博吗?")){
                axios.get("/weibo/delete?id="+id).then(function () {
                    location.reload();//刷新页面
                })
            }
        }
      }
  })
</script>
</body>
</html>